package com.yz.vi.commons.result;

/**
 * @description:
 * @author: yutingting
 * @create: 2021-01-22 09:58
 **/
public class CommonError {
    private String errorCode;
    private String errorMsg;
    private String location;
    private Throwable throwable;

    public CommonError() {
    }

    public CommonError(String code, String msg, String location) {
        this.errorCode = code;
        this.errorMsg = msg;
        this.location = location;
    }

    public CommonError(String code, String msg, String location, Throwable throwable) {
        this.errorCode = code;
        this.errorMsg = msg;
        this.location = location;
        this.throwable = throwable;
    }

    public String toDigest() {
        return this.errorCode + "@" + this.location;
    }

    public String getErrorCode() {
        return this.errorCode;
    }

    public String getErrorMsg() {
        return this.errorMsg;
    }

    public String getLocation() {
        return this.location;
    }

    public Throwable getThrowable() {
        return this.throwable;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public void setThrowable(Throwable throwable) {
        this.throwable = throwable;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof CommonError)) {
            return false;
        } else {
            CommonError other = (CommonError)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label59: {
                    Object this$errorCode = this.getErrorCode();
                    Object other$errorCode = other.getErrorCode();
                    if (this$errorCode == null) {
                        if (other$errorCode == null) {
                            break label59;
                        }
                    } else if (this$errorCode.equals(other$errorCode)) {
                        break label59;
                    }

                    return false;
                }

                Object this$errorMsg = this.getErrorMsg();
                Object other$errorMsg = other.getErrorMsg();
                if (this$errorMsg == null) {
                    if (other$errorMsg != null) {
                        return false;
                    }
                } else if (!this$errorMsg.equals(other$errorMsg)) {
                    return false;
                }

                Object this$location = this.getLocation();
                Object other$location = other.getLocation();
                if (this$location == null) {
                    if (other$location != null) {
                        return false;
                    }
                } else if (!this$location.equals(other$location)) {
                    return false;
                }

                Object this$throwable = this.getThrowable();
                Object other$throwable = other.getThrowable();
                if (this$throwable == null) {
                    if (other$throwable != null) {
                        return false;
                    }
                } else if (!this$throwable.equals(other$throwable)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof CommonError;
    }

    public int hashCode() {

        int result = 1;
        Object $errorCode = this.getErrorCode();
        result = result * 59 + ($errorCode == null ? 43 : $errorCode.hashCode());
        Object $errorMsg = this.getErrorMsg();
        result = result * 59 + ($errorMsg == null ? 43 : $errorMsg.hashCode());
        Object $location = this.getLocation();
        result = result * 59 + ($location == null ? 43 : $location.hashCode());
        Object $throwable = this.getThrowable();
        result = result * 59 + ($throwable == null ? 43 : $throwable.hashCode());
        return result;
    }

    public String toString() {
        return "CommonError(errorCode=" + this.getErrorCode() + ", errorMsg=" + this.getErrorMsg() + ", location=" + this.getLocation() + ", throwable=" + this.getThrowable() + ")";
    }
}
